import React, { Component } from 'react';
import qs from 'querystringify'

class Params extends Component {
  componentDidMount() {
    // 处理url的参数
    let str = this.props.location.search;
    // 1.通过URLSearchParams 的get方法
    let urlData = new URLSearchParams(str)
    console.log(urlData.get('age'));
    console.log(urlData.get('job'));
    // ================
    // 2. 通过querystringify处理参数
    let obj = qs.parse(str);
    console.log(obj);
  }
  render() {
    return (
      <div>
        <p>获取url上的参数</p>
      </div>
    );
  }
}

export default Params;
